package com.lu.statistics.service.cart;

import com.lu.statistics.entity.MtDishCategories;
import com.lu.statistics.entity.MtDishInfo;
import com.lu.statistics.entity.RCustomerCart;
import com.lu.statistics.entity.enums.GoodsTypeEnum;
import com.lu.statistics.mapper.MtDishInfoMapper;
import com.lu.statistics.mapper.RCustomerCartMapper;
import com.lu.statistics.service.CartTypeService;
import com.lu.statistics.service.DishCategoriesService;
import com.lu.statistics.service.DishInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DishSingleServiceImpl implements CartTypeService {
    @Autowired
    private RCustomerCartMapper cartMapper;
    @Autowired
    private DishInfoService dishInfoService;
    @Override
    public void addCustomerCart(RCustomerCart customerCart) {
        MtDishInfo dish = dishInfoService.queryDishInfoById(customerCart.getProductId());
        customerCart.setProductName(dish.getDishName());
        customerCart.setImgUrl(dish.getImgUrl());
        customerCart.setImgName(dish.getImgName());
        customerCart.setDescribes(dish.getDescribes());
        customerCart.setCartStatus(0);
        customerCart.setProductType(customerCart.getProductType());
        cartMapper.insert(customerCart);
    }

    @Override
    public String getType() {
        return GoodsTypeEnum.CUISINE.name();
    }
}
